<template>
  <section>
    <el-form label-width="80px">
      <el-form-item label="标题">
        <el-input size="mini" style="width: 200px" v-model="typeForm.name"></el-input>
      </el-form-item>
      <el-form-item label="编码">
        <el-input size="mini" style="width: 200px" v-model="typeForm.code"></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-button size="mini" type="success" @click="saveBtn">保存</el-button>
      </el-form-item>
    </el-form>
  </section>
</template>

<script>
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import Vue from 'vue'//后续添加属性，需要vue联动
  import errHandler from '@/assets/errHandler'
  export default {
    name: "editExamineType",
    props:['typeForm'],
    data(){
      return{
        reportTemplateList:null,
        totalPage:0,
        searchKey:null
      }
    },
    created(){
    },
    computed:{
      ...mapGetters(['department']),
    },
    watch: {
    },
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      saveBtn(){
        console.log('看下体检定义--------',this.typeForm)
        if(this.typeForm.id) this.updateExamineType(this.typeForm)
        else this.createExamineType(this.typeForm)
      },
      createExamineType(data){
        this.fetch({name:"createExamineType",data:{...data,departmentCode: this.department.code}})
          .then(res=>{
            console.log('创建成功---------',res)
            this.$emit('success')
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
      updateExamineType(data){
        this.fetch({name:"updateExamineType",data})
          .then(res=>{
            console.log('更新成功---------',res)
            this.$emit('success')
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      }
    }
  }
</script>

<style scoped>

</style>
